
<?php 
	require_once  __DIR__ . '/includes/authenticate.php';
	include_once './db_bb_connect.php';
	?>

 
<div class="container-fluid">
<div class="row">
<div class="col-md-12">

<div class="text-center"><h3>Add New Player Note</h3></div>

<form method="POST" action="">
    <div class="form-group">
	  <div class="col-md-offset-3 col-md-6">        
          <select class="form-control" name="playerID">
         	<option value="" disabled="disabled" selected="selected">Select a player</option>

<?php

$sql = "SELECT firstname, lastname, user_key, type
FROM users 
WHERE users.type = 'Player'
ORDER BY firstname";

$result=$db->query($sql);

while($row=$result->fetch_assoc()){	

  $user_key=$row['user_key']; 
  $firstname=$row['firstname']; 
  $lastname=$row['lastname']; 
  
  echo "<option value='$user_key'>$firstname $lastname</option>";

}

  ?>

          </select>
          <br>

<select class="form-control" name="category">
         	<option value="" disabled="disabled" selected="selected">Select a category</option>
         	<option value="personal">Personal</option>
         	<option value="fundamentals">Fundamentals</option>
         	<option value="training">Training</option>
         	<option value="game">Game</option>
         	<option value="injuries">Injuries</option>
</select>
<br>

           <div class="form-group">
            <div class="input-group">
                <input type="date" class="form-control" name="date" placeholder="YYYY-MM-DD" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar">
                    </span>
                </span>
            </div>
            </div>


<br>
 <textarea class="form-control" rows="4"  name="fulltext"></textarea> 
<br><br>

	<button type="submit" class="btn btn-success col-md-offset-3"> Submit new note </button>

	</div>
</div>		
	

  </form>
</div>
</div>
</div>




<script type="text/javascript">

$("form").on("submit", function(event) {
    postData = $( this ).serialize();
    event.preventDefault();
    callAddPlayerNote(postData);
});


function callAddPlayerNote(e, postData){
  $.ajax({
  type: "POST",
  url: "./includes/handlers/playerprofile_add_handler.php",
  data: this.postData,
  success: function(data) {
    $("#playerprofilecontent").html(data);
  }
  }); 

  e.preventDefault();
};

</script>

